﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;

namespace School.SystemManage.WebPages.UserManage
{
    public partial class UserInfo : BasePage
    {
        TechnologySchoolEntities db = new TechnologySchoolEntities();

        protected void Page_Load(object sender, EventArgs e)
        {
            int uid = int.Parse(GetCookie("UserLoginID"));
            //var user = db.AdminUsers.FirstOrDefault(u => u.UserID == uid);
            var user = (from u in db.AdminUsers
                       where u.UserID == uid
                       select new
                       {
                           u.UserName,
                           u.UserPwd,
                           u.RealName,
                           u.Role,
                           u.LoginTime
                       }).FirstOrDefault();
            if (user != null)
            {
                lblUserName.Text = user.UserName;
                lblPwd.Text = Security.Cryptography.AESDecrypt(user.UserPwd, "technology");
                lblRealName.Text = user.RealName;
                lblLoginTime.Text = user.LoginTime.ToString();
                lblRole.Text = user.Role.RoleName;
            }
        }
    }
}
